{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "758e195f-03ca-4623-bcd7-09322979f643",
   "metadata": {},
   "outputs": [],
   "source": [
    "from PIL import Image\n",
    "from torchvision import transforms\n",
    "import numpy as np\n",
    "from torch.utils.tensorboard import SummaryWriter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "511fad93-2e36-4897-9a48-b418e7f90ec3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=742x1024 at 0x284C0378050>\n"
     ]
    }
   ],
   "source": [
    "img_path = r\"D:\\desktop\\dog.jpg\"\n",
    "img = Image.open(img_path)\n",
    "print(img)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "027bdd6d-b433-4ada-8da1-01fc33a06db2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "torch.Size([3, 1024, 742])"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tensor_trans = transforms.ToTensor()\n",
    "img_tensor = tensor_trans(img)\n",
    "img_tensor.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "c787cba6-6552-47fd-867d-042012861e09",
   "metadata": {},
   "outputs": [],
   "source": [
    "writer = SummaryWriter(\"logs\")\n",
    "writer.add_image(\"imgtensor\",img_tensor)\n",
    "writer.close()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
